home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
PIL
/
BdfFontFile.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
3KB
|
102 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import Image
import FontFile
import string
bdf_slant = {
'R': 'Roman',
'I': 'Italic',
'O': 'Oblique',
'RI': 'Reverse Italic',
'RO': 'Reverse Oblique',
'OT': 'Other' }
bdf_spacing = {
'P': 'Proportional',
'M': 'Monospaced',
'C': 'Cell' }
def bdf_char(f):
while None:
s = f.readline()
if not s:
return None
if s[:9] == 'STARTCHAR':
break
continue
continue
id = string.strip(s[9:])
props = { }
while None:
s = f.readline()
if not s or s[:6] == 'BITMAP':
break
i = string.find(s, ' ')
props[s[:i]] = s[i + 1:-1]
continue
bitmap = []
while None:
s = f.readline()
if not s or s[:7] == 'ENDCHAR':
break
continue
bitmap = string.join(bitmap, '')
(x, y, l, d) = map(int, string.split(props['BBX']))
(dx, dy) = map(int, string.split(props['DWIDTH']))
bbox = ((dx, dy), (l, -d - y, x + l, -d), (0, 0, x, y))
try:
im = Image.fromstring('1', (x, y), bitmap, 'hex', '1')
except ValueError:
im = Image.new('1', (x, y))
return (id, int(props['ENCODING']), bbox, im)
class BdfFontFile(FontFile.FontFile):
def __init__(self, fp):
FontFile.FontFile.__init__(self)
s = fp.readline()
if s[:13] != 'STARTFONT 2.1':
raise SyntaxError, 'not a valid BDF file'
props = { }
comments = []
while None:
s = fp.readline()
if not s or s[:13] == 'ENDPROPERTIES':
break
i = string.find(s, ' ')
props[s[:i]] = s[i + 1:-1]
if s[:i] in ('COMMENT', 'COPYRIGHT'):
if string.find(s, 'LogicalFontDescription') < 0:
comments.append(s[i + 1:-1])
continue
font = string.split(props['FONT'], '-')
font[4] = bdf_slant[string.upper(font[4])]
font[11] = bdf_spacing[string.upper(font[11])]
ascent = int(props['FONT_ASCENT'])
descent = int(props['FONT_DESCENT'])
fontname = string.join(font[1:], ';')
font = []
while None:
c = bdf_char(fp)
if not c:
break
(xy, dst, src) = (id, ch)
im = c
if ch >= 0 and ch < len(self.glyph):
self.glyph[ch] = (xy, dst, src, im)
continue
continue
return None